﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RonYee.Models;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;

namespace RonYee.Models
{
    //图书表
    public class Book
    {
        public int BookId { get; set; }

        public string ISBN { get; set; }

        public string BookName { get; set; }

        public string Publisher { get; set; }

        public string PublishNum { get; set; }

        public string Author { get; set; }

        public int BookCount { get; set; }

        public decimal OriginalPrice { get; set; }

        public decimal CurrentPrice { get; set; }

        public string BookImage { get; set; }

        public string DelImgUrl { get; set; }

        public string BookType1 { get; set; }

    }

    //书库内每本图书信息表
    public class InStore
    {
        public int InStoreId { get; set; }

        [Required(ErrorMessage = "必须输入ISBN！")]
        public string ISBN { get; set; }

        [Required(ErrorMessage = "必须输入书名！")]
        public string BookName { get; set; }

        [Required(ErrorMessage = "必须输入仓储位置")]
        public string StorageArea1 { get; set; }

        [Required(ErrorMessage = "必须输入仓储位置")]
        public string StorageArea2 { get; set; }

        [Required(ErrorMessage = "必须输入编辑时间")]
        public DateTime AddTime { get; set; }

        [Required(ErrorMessage = "必须输入书籍条目编辑人")]
        public string Editor { get; set; }

        [Required(ErrorMessage = "必须输入持有者信息")]
        public string HoldUser { get; set; }
    }

    //财务表
    public class Financial
    {
        public int Id { get; set; }
        public string OrderId { get; set; }
        public decimal Total { get; set; }
        public decimal FinancialCost { get; set; }
        public DateTime AddTime { get; set; }
        public string Editor { get; set; }

    }

    //客户表
    public class Customer
    {
        public int CustomerId { get; set; }

        public string CustomerNo { get; set; }

        public string Login { get; set; }

        public string Email { get; set; }

        public string Phone { get; set; }

        public int UserType { get; set; }

        public string Colloge { get; set; }

        public string CarNo { get; set; }

        public DateTime AddTime { get; set; }

        public int status { get; set; }
    }

    //文件表
    public class File
    {
        public int FileId { get; set; }

        public int NewsId { get; set; }

        [Required(ErrorMessage = "必须输入文件名称！")]
        public string FileName { get; set; }

        [Required(ErrorMessage = "FileUrl是必填字段")]
        public string FileUrl { get; set; }

        [Required(ErrorMessage = "FileMineType是必填字段")]
        public string FileMineType { get; set; }

        [Required(ErrorMessage = "AddTime是必填字段")]
        public DateTime AddTime { get; set; }

        [Required(ErrorMessage = "EditUser是必填字段")]
        public string EditUser { get; set; }

        public int FileType1 { get; set; }
    }

    //Slider表
    public class ImgNews
    {
        public int ImgNewsId { get; set; }

        public string ImgName { get; set; }

        [Required(ErrorMessage = "请输入Slider新闻标题！")]
        public string ImgTitle { get; set; }

        [Required(ErrorMessage = "请输入Slider新闻摘要！")]
        public string Brief { get; set; }

        [Required(ErrorMessage = "Slider图片位置不能为空！")]
        public string ImgUrl { get; set; }

        public string DelUrl { get; set; }

        public string NewsUrl { get; set; }

        public string Editor { get; set; }

        public DateTime AddTime { get; set; }
    }

    //新闻表
    public class News
    {
        public int NewsId { get; set; }

        [Required(ErrorMessage = "请输入新闻标题！")]
        public string NewsTitle { get; set; }

        [Required(ErrorMessage = "请输入新闻内容！")]
        public string Contents { get; set; }

        public int ClickNum { get; set; }

        [Required(ErrorMessage = "EditUser为必填字段！")]
        public string Editor { get; set; }

        [Required(ErrorMessage = "AddTime为必填字段！")]
        public DateTime AddTime { get; set; }

        [Required(ErrorMessage = "请选择新闻类别！")]
        public int NewsType1 { get; set; }

        public int NewsType2 { get; set; }
    }

    //订单表
    public class Order
    {
        public int OrderId { get; set; }
        public string Username { get; set; }
        public string UserNo { get; set; }
        public int Status { get; set; }
        public string Phone { get; set; }
        public string Email { get; set; }
        public decimal Total { get; set; }
        public DateTime OrderDate { get; set; }
        public List<OrderDetail> OrderDetails { get; set; }
    }

    //购物车表
    public class Cart
    {
        [Key]
        public int RecordId { get; set; }
        public string CartId { get; set; }
        public int BookId { get; set; }
        public string ISBN { get; set; }
        public string BookName { get; set; }
        public int Count { get; set; }
        public DateTime DateCreated { get; set; }
        public virtual Book Book { get; set; }

    }

    //订单详细表
    public class OrderDetail
    {
        [Key]
        public int OrderDetailId { get; set; }
        public int OrderId { get; set; }
        public int BookId { get; set; }
        public string ISBN { get; set; }
        public string BookName { get; set; }
        public int Quantity { get; set; }
        public decimal UnitPrice { get; set; }
        public virtual Book Book { get; set; }
        public virtual Order Order { get; set; }
    }

    //数据库
    public class RongeDb : DbContext
    {

        public DbSet<News> Newss { get; set; }
        public DbSet<ImgNews> ImgNewss { get; set; }
        public DbSet<File> Files { get; set; }
        public DbSet<Book> Books { get; set; }
        public DbSet<Cart> Carts { get; set; }
        public DbSet<Order> Orders { get; set; }
        public DbSet<OrderDetail> OrderDetails { get; set; }
        public DbSet<InStore> InStores { get; set; }
        public DbSet<Financial> Financials { get; set; }
        public DbSet<Customer> Customers { get; set; }

    }

}